Conversation
- 서버에서 오는 에러 객체
- server, client 둘 다 사용 가능
- 로그아웃 API 응답 형식을 변경하여 빈 배열을 반환하도록 수정 - useLogoutMutation 훅을 생성하여 로그아웃 로직을 통합 - 로그아웃 성공 시 GTM 이벤트 전송 및 쿠키 삭제, React Query 캐시 초기화, 로그인 페이지로 리다이렉트 추가
Contributor
|
axios Instance 관련해서는 저도 비슷하지만 조금 다른 작업을 진행 하고 있었습니다. 저는 다음과 같이 구분해서 사용예정이었습니다. 기존 axiosInstance(토큰 없음) ->generalRequest[네이밍변경], 서버컴포넌트 요청관련은 현재 동작 플로우 테스트가 성공하지를 못해 아직 로직이 불분명해서 따로 생성하거나 추상화작업을 하지 않았습니다. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🌱 연관된 이슈
Qnrr 434
☘️ 작업 내용
당장 이 코드를 develop에 머지할 건 아니고, 환경에 따라 axios 분리했는데 그 부분에 대해 조언을 얻고싶어 미리 올립니다.
toast 컴포넌트 추가
shadcn에서 toast는 sonner 라이브러리를 설치하라고 명시되어 있습니다. 저번 회의때 이야기 나눈 것처럼, 그 라이브러리를 설치하여 구현하였습니다.
ApiError 클래스 생성
에러 응답 바디에 statusCode, errorCode, errorName, message가 담겨서 옵니다.
그래서 에러 응답이 오면 ApiError를 throw하여 대처할 수 있도록, ApiError 클래스를 만들었습니다.
(근데, 서버에서 ApiError 객체를 throw해도 errorCode와 같은 세부적인 내용이 클라이언트로 전송되지 않을 수 있다고 하네요💦 맞다면, Error 객체를 상속받지 않는 방법으로 수정할 것 같아요.)
axios 분리
axios instance를 분리하였습니다. 크게 3가지로 나뉩니다.
분리한 이유는 RSC와 RCC에서 access token을 가져오는 방식이 달라서입니다. RSC에서는 cookies로, RCC에서는 document로 가져오고 있습니다. RSC에서도 refresh token으로 access token을 재발급 받는 로직이 필요하다고 생각하기에, 둘을 구분하였습니다.
그래서 RSC에서 access token이 필요한 api에 요청할 경우 axiosServerInstance를, RCC에서 access token이 필요한 요청일 경우 axiosClientInstance를 사용하면 됩니다.
access token이 필요하지 않다면, axiosAllInstance를 사용하면 됩니다.
axiosClientInstance와 axiosServerInstance에서 errorCode가 AUTH001인 경우, access token 재갱신 요청하는 로직이 들어가야 합니다. 이 부분은 연환님과 논의가 필요할 것 같아요.